package com.bm.server.service.impl;

import com.bm.server.dto.LotDto;
import com.bm.server.util.Rutils;
import com.bm.server.vo.R;
import com.bm.server.dao.LotDao;
import com.bm.server.entity.Lot;
import com.bm.server.entity.UserInfo;
import com.bm.server.service.intf.LotService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Description:
 * @Author: 赵金帅
 * @Date: 2022/07/19/20:19
 */
@Service
public class LotServiceimpl  implements LotService {
    @Resource
    private LotDao dao;

    @Override
    public R save(LotDto dto) {
        if (dto!=null){
            Lot lot = new Lot();
            lot.setUid(dto.getUid());
            lot.setBid(dto.getBid());
            if (dao.insert(lot)>0){
                return Rutils.ok();
            }
        }
        return Rutils.fail();
    }

    @Override
    public R select(long uid) {
        if (uid>0){
            while (true){
                UserInfo userinfo = dao.selectUserOne();
                if (userinfo.getUid()!=uid) {
                    return Rutils.ok(userinfo);
                }
            }
        }
          return Rutils.fail();
    }
}
